package com.baizhi.dcx.controller;

import com.baizhi.dcx.entity.Admin;
import com.baizhi.dcx.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.Map;

@CrossOrigin
@Controller
@RequestMapping("admin")
public class AdminController {
    @Autowired
    private AdminService adminService;
    @RequestMapping("getImageCodes")
    @ResponseBody
    Map<String,String> getImageCodes() throws IOException {
        return adminService.getlmageCodes();
    }
    @RequestMapping("login")
    @ResponseBody
    Map<String,String> login(@RequestBody Admin admin,String token){
        return adminService.queryByUsername(admin,token);
    }
    @RequestMapping("getUserInfo")
    @ResponseBody
    Admin getUserInfo(String token){
        return adminService.getUserInfo(token);
    }
    @RequestMapping("logout")
    @ResponseBody
    void logout(String token){
         adminService.logout(token);
    }
}
